﻿@model QuanLyGiaoVuUI.Models.SinhVien.SinhVienViewModel
@{
    Layout = null;
}
<style>
    table.capnhatsv {
        width:80%;
        margin:0 auto;
    }
</style>

<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<div>
    @if(Model!=null){
        <div><input type="hidden" id="svid" value="@Model.ID" /></div>
        <table class="data display datatable capnhatsv">
            <tr>
                <th>Mã sinh viên:</th>
                <td><input type="text" id="masv" value="@Model.MaSinhVien"/></td>
                </tr>
                <tr><th>Họ tên:</th>
                    <td><input type="text" id="hotensv" value="@Model.HoTenSV"/></td>
                </tr>
                <tr><th>Giới tính:</th>
                    <td>
                        <select id="gioitinhsv">
                            @if (Model.GioiTinh > 0)
                            {
                                <option value="1" selected="selected">Nam</option>
                                <option value="0" >Nữ</option>
                            }else{
                                <option value="1" >Nam</option>
                                <option value="0" selected="selected">Nữ</option>
                            }
                        </select>
                    </td>
                </tr>
                <tr><th>Ngày sinh:</th>
                    <td><input type="text" id="ngaysinh" class="date_picker" value="@Model.NgaySinh.ToShortDateString()" />(mm/dd/yyyy)</td>
                </tr>
                <tr><th>Quê quán:</th>
                    <td><input type="text" id="quequansv" value="@Model.QueQuan" /> </td>
                </tr>
                <tr><th>Địa chỉ:</th>
                    <td><input type="text" id="diachisv" value="@Model.DiaChi" /> </td>
                </tr>
                <tr><th>Email:</th>
                    <td><input type="text" id="emailsv" value="@Model.Email" /> </td>
            </tr>
            <tr><td></td><td><input type="button" id="capnhat" value="Cập nhật" /></td></tr>
        </table>
    }
</div>

<script>
    $(document).ready(function () {

        $(".date_picker").datepicker();

        var url = "";
        $("#capnhat").click(function () {
            var svid = $("#svid").val();
            var masv = $("#masv").val();
            var hotensv = $("#hotensv").val();
            var gioitinhsv = $("#gioitinhsv").val();
            var ngaysinh = $("#ngaysinh").val();
            var quequansv = $("#quequansv").val();
            var diachisv = $("#diachisv").val();
            var emailsv = $("#emailsv").val();
            //alert(svid + masv + hotensv + gioitinhsv + ngaysinh + quequansv + diachisv + emailsv);
            $.post("/QuanLySinhVien/CapNhatSinhVien", { svid: svid, masv: masv, hotensv: hotensv, gioitinhsv: gioitinhsv, ngaysinh: ngaysinh, quequansv: quequansv, diachisv: diachisv, emailsv: emailsv }, function (data) {
                ThongBao(data);
            });
        });
    });
    function reloadPage(url) {
        window.location = url;
    }
    function ThongBao(data) {
        if (data.success) {
            ToastManager.showSuccessToast(data.message);
            var lopsv=$("#LopSinhVien").val();
            LoadDSSinhVien(lopsv);
        }
        else {
            ToastManager.showStickyWarningToast(data.message);
        }
    }
</script>